package com.os.serviceimpl;

import com.os.dao.RoleDaoM;
import com.os.daoimpl.RoleDaoImplM;
import com.os.service.LoadTreeFuncServiceM;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
 * 功能分配操作
 * @author MWX
 *
 */
public class LoadTreeFuncServiceImplM implements LoadTreeFuncServiceM{
     RoleDaoM rdm=new RoleDaoImplM();
	public JSONArray loadFuncByUid(int uid, int pid) {
		JSONArray js=rdm.getFuncByUid(uid, pid);
		for(int i=0;i<js.size();i++){
			JSONObject j=js.getJSONObject(i);
			if(j.get("state").equals("open")){
				continue;
			}else{
				JSONArray  childrens = this.loadFuncByUid(uid, j.getInt("id"));
				
				j.put("children", childrens);
			}
		}
		//System.out.println(js);
		return js;
		
	}

}
